package jin.si.com.service.impl;

import jin.si.com.dao.UserDao;
import jin.si.com.entity.Person;
import jin.si.com.entity.User;
import jin.si.com.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * @ClassName UserServiceImpl
 * @Author MT
 * @Date 2021/5/5 11:36
 **/

@Service
public class UserServiceImpl implements UserService {
    public static Map sessionMap=new HashMap();

    @Autowired
    private UserDao dao;

    @Override
    public List<User> getUsers() {
       List<User> list=new ArrayList<>();
       User user=new User();
       user.setId(1001);
       user.setName("臭宝宝");
       user.setSex("男");
       user.setAge(20);
       list.add(user);

       return list;
    }

    //json注解
    @Override
    public List<Person> getPerson1() {
        List<Person> list=new ArrayList<>();
        Person p1=new Person();
        p1.setId(1001);
        p1.setName("臭宝宝");
        p1.setPassword("12345");

        Person p2=new Person();
        p2.setId(1002);
        p2.setName("大橙子");
        p2.setPassword("56789");
        p2.setDate(new Date());

        list.add(p1);
        list.add(p2);
        return list;
    }

    @Override
    public String loginUser(String name, String pwd) {
        User user=new User();
        user.setName("臭宝宝");
        user.setPwd("12345");
        if(user!=null){
            String token=UUID.randomUUID().toString();
            sessionMap.put(token,user);
            return token;
        }else{
            return null;
        }
    }

    //获取用户信息
    @Override
    public List<User> getUser() {
        List<User> user = dao.getUser();
        return user;
    }


}
